from django.urls import path, re_path, include
from django.views.generic import TemplateView
from django.views.static import serve

import xadmin

from user.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetView, ModifyPwdView
from MxOnline.settings import MEDIA_ROOT


urlpatterns = [
    path('xadmin/', xadmin.site.urls),
    path('', TemplateView.as_view(template_name='index.html'), name="index"),
    path('login/', LoginView.as_view(), name="login"),    
    path('register/', RegisterView.as_view(), name="register"),
    path('captcha/', include('captcha.urls')),
    re_path('active/(?P<active_code>.*)/$', ActiveUserView.as_view(), name='user_active'),
    path('forget/', ForgetPwdView.as_view(), name='forget_pwd'),
    re_path('reset/(?P<active_code>.*)/$', ResetView.as_view(), name='reset_pwd'),
    path('modify_pwd/', ModifyPwdView.as_view(), name='modify_pwd'),

    # 课程机构url配置
    path('org/', include(('organization.urls','org'), namespace='org')),

    # 课程相关url配置
    path('course/', include(('courses.urls', 'course'), namespace='course')),

    # 配置上传文件的访问处理函数
    re_path('media/(?P<path>.*)$',  serve, {'document_root': MEDIA_ROOT}),
]
